﻿// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
#include "pch.h"
#include "LogMessageToColorConverter.h"
#include "Logger.h"

using namespace Weathr;

using namespace Platform;
using namespace Windows::UI::Xaml::Interop;

String^ DefaultColor = "White";

Object^ LogMessageToColorConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
{
    (void) targetType;	// Unused parameter
    (void) parameter;	// Unused parameter
    (void) language;	// Unused parameter

    auto message = dynamic_cast<LogMessage^>(value);
    if (message == nullptr)
    {
        return DefaultColor;
    }

    switch (message->Kind)
    {
    case LogMessageKind::Info:
        return "LightGreen";
    case LogMessageKind::Warning:
        return "LightYellow";
    case LogMessageKind::Error:
        return "OrangeRed";
    case LogMessageKind::AsyncAction:
        return "Yellow";
    default:
        assert(false);
        return DefaultColor;
    }
}

Object^ LogMessageToColorConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
{
    (void) value;
    (void) targetType;	// Unused parameter
    (void) parameter;	// Unused parameter
    (void) language;	// Unused parameter

    throw ref new NotImplementedException();
}
